package com.hand.demo.infra.util;


import com.hand.demo.domain.entity.Example;
import org.codehaus.jackson.map.ObjectMapper;
import org.hzero.boot.imported.app.service.ValidatorHandler;
import org.hzero.boot.imported.infra.validator.annotation.ImportValidator;
import org.hzero.boot.imported.infra.validator.annotation.ImportValidators;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;

/**
 * @author yufan.yao@hand-china.com 2023/9/23 22:47
 */
/*@ImportValidators({
        //可以填写多个
        @ImportValidator(templateCode = "Demo_Client")
})
public class Validator extends ValidatorHandler {
    @Autowired
    private ObjectMapper objectMapper;
    @Override
    public boolean validate(String data) {
        Example example=new Example();
        try {
            objectMapper.readValue(data,Example.class);
        } catch (IOException e) {
           return false;
        }
        if (example.getName().equals("李四")){
            getContext().addErrorMsg("李四为敏感信息");
            return false;
        }
        return true;
    }
}*/
